package semiProject_army.mvc.action;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import semiProject_army.mvc.beans.MemberBean;
import semiProject_army.mvc.beans.MemberDAO;

public class JoinWriteAction implements ActionHandler {

	@Override
	public String execute(HttpServletRequest req, HttpServletResponse res)
			throws IOException, ServletException {
		
			req.setCharacterEncoding("UTF-8");
		
			MemberDAO dao = MemberDAO.getInstance();
							
			req.setAttribute("action", "member/joinok");
			
			MemberBean member = new MemberBean();
			
			member.setUserName(req.getParameter("userName"));
			member.setUserId(req.getParameter("userId"));
			member.setUserPw(req.getParameter("userPw"));
			member.setUserEmail(req.getParameter("userEmail"));
			member.setUserPhon(req.getParameter("userPhon"));
			
			
			System.out.println(req.getParameter("userName"));
			System.out.println(req.getParameter("userPhon"));
			int result = dao.joinMember(member);
			
			System.out.println(result);
			
			req.setAttribute("result", result);
			
			
			
		return viewPage;
	}
	
}